﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using LeoShi.Soft.OpenSinaAPI;

namespace Shoping.Monitor
{
    public partial class Login : Form
    {
        private readonly string _url;


        public Login(string url)
        {
            InitializeComponent();
            _url = url;
            this.webBrowser1.Url = new Uri(url);
        }

        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            var url = this.webBrowser1.Url.AbsoluteUri;
           
            if (url.Contains("code="))
            {


                Code = Regex.Match(url, "(?<=(code=)).*$").ToString();

                this.DialogResult = DialogResult.OK;

               
            }

        }

        public string Code { get; set; }
    }
}
